package f5transformation.aggregation;


import flinkemp.Emp;
import flinkemp.EmpFun;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class KeyByMax {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<Emp> data = env.addSource(new EmpFun());
        data.print();
        data.keyBy(new KeySelector<Emp, Integer>() {
            @Override
            public Integer getKey(Emp emp) throws Exception {
                return emp.deptNo;
            }
        }).maxBy("sal")
                .print();
        env.execute();
    }
}
